
<style>
table{
	border: 1px solid black;
	width: 700px;
	text-align: center;
	margin:0 auto;
}
th{
	background-color: white;
	border: 1px solid black;
}
td{
	border: 1px solid black;
}
</style>
<form action="search.php" method="post">
<table>
<tr><td colspan="8">请选择你要查询的字段
<select name="ziduan">
						<option value="id">id</option>
						<option value="major">major</option>
						<option value="class">class</option>
						<option value="student_id">student_id</option>
						<option value="name">name</option>
						<option value="birthday">birthday</option>
</select>
请输入你要查询的内容
<input type="text" name="neirong">
<input type="submit" value="搜索" name="selsub"">
</td></tr></table>
</form>
<table>
<form action="#" method="post">
<tr><th>ID</th>
<th>专业</th><th>班级</th><th>学号</th><th>姓名</th><th>性别</th><th>出生日期</th></tr>

<?php
$servername = "192.168.56.103"; // MySQL 主机名
$username = "root"; // MySQL 用户名
$password = "123456"; // MySQL 密码
$dbname = "myDB"; // 要连接的数据库名称

// 创建连接
$link = new mysqli($servername, $username, $password, $dbname);
mysqli_query($link,"set names utf8");
$query = "select * from students";
$result = mysqli_query($link,$query)or die("执行语句失败");
$count = 0;
while($arr = mysqli_fetch_assoc($result)){
	$count++;
	$alt = ($count % 2)?"alt":"";
	echo"<tr class={$alt}><td>{$arr['id']}</td><td>{$arr['major']}</td>".
	"<td>{$arr['class']}</td><td>{$arr['student_id']}</td>".
	"<td>{$arr['name']}</td><td>{$arr['sex']}</td><td>{$arr['birthday']}</td>";
}
mysqli_free_result($result);
mysqli_close($link);
?>
</form>
</table>
<center>
  <button onclick="location.href='edit.php'">添加数据</button>
</center>


